﻿#region Usings

using System;
using System.Xml.XPath;
using Yandex.Market.Api.YmlSerialization;

#endregion

namespace Yandex.Market.Api.Model
{
    [YmlSerializeAs("ordering")]
    [Serializable]
    public class Ordering
    {
        [YmlValueForClass]
        public string Value { get; set; }

        [YmlSerializeAs("hours")]
        [YmlAttributeForClass]
        public string Hours { get; set; }

        internal static Ordering CreateOrderingFromXml(XPathNavigator nav)
        {
            Ordering ordering = new Ordering();
            ordering.Value = nav.Value;

            string hours = nav.GetAttribute("hours", "");
            if(!string.IsNullOrEmpty(hours))
                ordering.Hours = hours;

            return ordering;
        }
    }
}